home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AOL File Library: 2,801 to 2,900
/
aol-file-protocol-4400-2801-to-2900.zip
/
AOLDLs
/
C++ Files Library
/
3D & Offscreen for MacApp 3
/
3D & Offscreen Sample.sea
/
3D & Offscreen Sample
/
Read Me
< prev
next >
Wrap
Text File
|
1993-07-02
|
6KB
|
157 lines
Offscreen
This package contains three interesting classes. One, I hope will greatly help people in
the use of Offscreen GWorlds. These classes help do (almost) transparent offscreen manipulation
in views for MacApp 3.0.1. All you do to get all drawing done in an offscreen GWorld
is attach an adorner to any view (or multiple views) and everything is taken care of (almost).
Enc.
TOffscreenAdorner.h
TOffscreenAdorner.cp
TOffscreenDrawEnvironment.h
TOffscreenDrawEnvironment.cp
To use these classes, make the following calls:
From the any views DoPostCreate
TOffscreenAdorner* aOffscreenAdorner = new TOffscreenAdorner;
aOffscreenAdorner->IOffscreenAdorner('OffA', true, true );
this->AddAdorner (aOffscreenAdorner, kAdornFirst, false);
or anywhere else
TOffscreenAdorner* aOffscreenAdorner = new TOffscreenAdorner;
aOffscreenAdorner->IOffscreenAdorner('OffA', true, true);
theView->AddAdorner (aOffscreenAdorner, kAdornFirst, false);
Explanation of Classes:
TOffscreenAdorner
This class, when attached to a view, will create and handle all
offscreen drawing. It does this by creating a TOffscreenDrawEnvironment
object and replaces the views current TDrawingEnvironment with
it. If for any reason offscreen drawing can't take place, then
normal drawing will occur. If RemoveFromView is called, the old
TDrawingEnvironment is replaced and the view acts normally.
Due to flaws in MacApp 3, this adorner must be manually attached to
the view. The reason is that TAdornerList::AddAdorner does not call
anAdorner->AddedToView(this), which notifies the adorner which view it
is attached to. This is called in TView::AddAdorner, which properly calls
the method.
TOffscreenDrawEnvironment
This Class is meant for transparent offscreen use in the MacApp 3
framework. It is a decendant of TDrawingEnvironment and is used as
one. However, due to several flaws in MacApp, neither this object nor
the Adorner we use can be used through ViewEdit (or Adlib).
THe reasons are that TDrawingEnvironment is created procedurally and
does not use the view creation. Thus even if a TOffscreenDrawEnvironment
is attatched, it will not be used. The way this class is loaded is by
attaching a TOffscreenAdorner to which ever view is using offscreen.
Under normal situations we would just add an adorner using Adlib
(Viewedit does not allow custom adorner creation). However, due to
another flaw in MacApp, this is not possible. If you add an adorner to
a view (using Adlib), MacApp 3 does not call TAdorner::AddedToView,
while the View stream is being read in.
SOooo... to get around this problem, you must add the adorner manaully.
Please note that these classes have only been partially tested, and may have bugs.
If anyone see's any way to improve these classes, or any bugs, please report
them to me, and I will maintain them. Also note that as yet these classes have not
been tested with subviews (well they were, but they didn't work ). So, as yet don't
add subviews to the view that does offscreen drawing.
Special thanks goes to Ken Ryall for his frameworks May 92 article.
I had already developed similar classes, before I read his article, but was unable to
solve a bug. His use of BeInPort solved it.
Bugs:
While use of one (the global) or many Gworlds is fine in different windows, use of 2
GWorlds in one window ( two views with the Offscreen attached) causes problems. I just
discovered this problem.
I use temp (multifinder) memory to allocate the GWorld. This can be problem for many
programs, but I have had strange results using keepLocal as my flag. If anyone knows
why this is so, please tell me.
3D
The second part of the package is an adaptation of VirtualSphere to MacApp 3.
I claim no credit for this, in so far that I only adapted the code to MacApp 3.
These set of classes use the 3DGrafPort that has been in the Macs OS for a long time.
Until recently, the machines where to slow to achive good speeds with the 3D manipuation.
( Trust me, I wrote some stuff way back on an SE and it was slow. ) These classes allow
use of the 3D port code by creating a TView subclass.
enc.
T3DObjectView.cp
T3DObjectView.h
T3DTracker.cp
T3DTracker.h
T3DView.cp
T3DView.h
TVirtualSphere3DTracker.cp
TVirtualSphere3DTracker.h
To use these classes:
All you have to do is add a T3DView to a window. By itself, T3DView doesn't do much
but you can subclass off it to allow all kinds of interesting things.
Also you must call in your main (although it really can be anywhere, as long as it is
called before any 3D stuff is done).
Port3DPtr gThePort3DPtr;
InitGrf3d (&gThePort3DPtr);
and include
#ifndef __GRAF3D__
#include <Graf3D.h>
#endif
Explanation of Classes:
T3DView
This class is the root class for all 3D operations. It creates the 3D
Port and maintains it. I plan on enhancing this class for more robust
use.
T3DObjectView
This class is the 3D workhorse. It's main function is to draw a polygon
based object to the port. This object can be almost anything, so long as
it is defined as a PolygonNetData structure (look in ObjectData.h).
This class does the set up and drawing and handles the menus. If a mouse
is clicked on it, a T3DTracker subclass is created.
T3DTracker
This class is an abstract class that handles 3D Trackers.
(I hope to add more functionaly to it later as I figure out new trackers)
TVirtualSphere3DTracker
This is the subclass of T3DTracker that acts like the Virtual Sphere
example program on ETO 10. This Class holds several methods that
determine the rotation for sphere.
Special thanks goes to Michael Chen, most of the 3D code is his. I just adapted
it to work with MacApp 3.
Bugs:
As yet, I don't know why the matrix loses its vectors sometimes. When the vector
becomes less then 0, the program normally would crash. So I destroy the matrix and start
over. I know its a cheat, but it will take some time to solve this.
Special thanks goes to Michael Chen who wrote VirtualSphere (on ETO). Most of this
code is his, and I have only adapted it.
Finally, feel free to use these classes to your hearts content. Share them,
and ALink me if you like them (or even if you don't).
Eric Hanig
ALink: ABI.FC
800-874-9868 ex 8902
AOL: Gimmel